package com.xlh.dokka.svc.task;

import com.xlh.dokka.svc.core.client.DockerClient;
import com.xlh.dokka.svc.core.client.Result;

import java.util.concurrent.Callable;

/**
 * @author cheer
 */
public class ImagePullTask implements Callable<Boolean> {

    private String ip;

    private String imageName;

    ImagePullTask(String ip, String imageName) {
        this.ip = ip;
        this.imageName = imageName;
    }

    @Override
    public Boolean call() {
        return DockerClient.ping(ip) && (DockerClient.pullImage(ip, imageName) != Result.SERVER_ERROR);
    }
}
